import numpy as np
import cv2
import matplotlib.pyplot as plt

img=plt.imread("1.png")
img=img[:,:,0:3]*255
img=img.astype("uint8")
img_bin = cv2.Canny(img, 50, 100, apertureSize=3)  # 进行边缘检测
plt.imshow(img_bin,cmap="gray")
plt.show()

img_out=cv2.HoughCircles(img_bin,cv2.HOUGH_GRADIENT,1,200,param1=200,param2=100,minRadius=100,maxRadius=400)

for i in img_out[0,:]:
    cv2.circle(img,(int(i[0]),int(i[1])),int(i[2]),(255,0,0),8)#绘制检测到的圆
plt.imshow(img,cmap="gray")
plt.show()


